/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package newkfp;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @author A7med Kotb
 */
public class TwicePreparedStatement {

    public static void main(String[] args) {
//        Connection con = null;
//        PreparedStatement prest;
//        try {
//            Class.forName("com.mysql.jdbc.Driver");
//            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/kfp", "root", "root");
//            try {
//                String sql = "SELECT t0.idBill_Item, t1.itemName, t2.CountryName, t3.FactoryName, SUM(t0.itemAmount), AVG(t0.itemPrice), SUM(t0.totalPrice), SUM(t0.packageCount)"
//                        + " FROM bill t5, bill t4, factory t3, country t2, item t1, bill_item t0"
//                        + " WHERE t0.itemID = t1.idItem AND t0.factoryID = t3.idFactory AND t2.idcountry = t3.idFactory AND t4.idBill =t0.billId  AND t4.createDate BETWEEN ? AND ? AND t5.idBill = t0.billID GROUP BY t1.itemName , t2.CountryName , t3.FactoryName;";
//                prest = con.prepareStatement(sql);
//                prest.setDate(1, fromDate);
//                prest.setDate(2, toDate);
//                ResultSet rs1 = prest.executeQuery();
//                while (rs1.next()) {
//                    String mov_name = rs1.getString(1);
//                    int mad_year = rs1.getInt(2);
//                    System.out.println(mov_name + "\t- " + mad_year);
//                }
//            } catch (SQLException s) {
//                s.printStackTrace();
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
    }
}